package org.bonorsoft.modules.wechat.entity;

import org.bonorsoft.modules.wechat.wxpay.sdk.IWXPayDomain;
import org.bonorsoft.modules.wechat.wxpay.sdk.WXPayConfig;

import java.io.InputStream;

public class MyConfig implements WXPayConfig {

    /* private byte[] certData;

    public MyConfig() throws Exception {
        String certPath = "/path/to/apiclient_cert.p12";
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }*/

    public String domain = "api.mch.weixin.qq.com";       //域名
    public boolean primaryDomain = true;     //该域名是否为主域名。例如:api.mch.weixin.qq.com为主域名

    public String getAppID() {
        return "wxf7b41fa89b384d55";
    }

    public String getMchID() {
        return "1601044829";
    }

    public String getKey() {
        return "DongYingBonorXinXiJiShu123456789";
    }

    public InputStream getCertStream() {
        //ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return null;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }

    @Override
    public IWXPayDomain getWXPayDomain() {
        IWXPayDomain iwxPayDomain = new IWXPayDomain() {
            @Override
            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }
            @Override
            public DomainInfo getDomain(WXPayConfig config) {
                DomainInfo domainInfo = new DomainInfo();
                domainInfo.domain = domain;
                domainInfo.primaryDomain = primaryDomain;
                return domainInfo;
            }
        };
        return iwxPayDomain;
    }


    @Override
    public boolean shouldAutoReport() {
        return true;
    }

    @Override
    public int getReportWorkerNum() {
        return 6;
    }

    @Override
    public int getReportQueueMaxSize() {
        return 10000;
    }

    @Override
    public int getReportBatchSize() {
        return 10;
    }
}
